package org.springcloud.wisdom.spring_02_classroom.admin.managestudent.controller;

import org.springcloud.wisdom.spring_02_classroom.admin.managestudent.service.ManageStudentService;
import org.springcloud.wisdom.spring_02_classroom.bean.BaseController;
import org.springcloud.wisdom.spring_02_classroom.bean.ResponseData;
import org.springcloud.wisdom.spring_02_classroom.student.sschedule.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/stu")
public class ManageStudentController extends BaseController {
    @Autowired
    private ManageStudentService manageStudentService;

    // 修改学生密码
    @PutMapping("/pwd")
    public ResponseData<Object> updateStudentPassword(@RequestBody Student student) {
        boolean success = manageStudentService.updateStudentPassword(student);
        return returnObject(success ? "修改成功！" : "修改失败！");
    }

    //基于课模糊查询学号和姓名的分页查看所有学生信息
    @RequestMapping("/all")
    public ResponseData<Object> getPage(@RequestParam("pageNum") int pageNum,
                                        @RequestParam("pageSize") int pageSize,
                                        @RequestParam(value = "sname",required = false) String sname,
                                        @RequestParam(value = "sid",required = false) String sid){
        return returnObject(manageStudentService.AllStudent(pageNum,pageSize,sid,sname));
    }
}
